package com.lg.online_shop.enmu;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum OrderEnum {
    UNPAID(0, "未支付"),
    PAID(1, "已支付"),
    DELETED(2, "已取消"),
    REFUND(3, "已退款"),
    REFUNDING(4, "退款中");


    private final int code;
    private final String description;

    // 通过 code 获取对应的枚举项
    public static OrderEnum fromCode(int code) {
        for (OrderEnum status : OrderEnum.values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的订单状态码: " + code);
    }
}